home *** CD-ROM | disk | FTP | other *** search
/ Merciful 5 / Merciful - Disc 5.iso / software / p / pcqpascalv1.2d.lha / Include / Utility / Pack.i < prev    next >
Text File  |  1997-05-06  |  5KB  |  134 lines

  1.    {    Control attributes for Pack/UnpackStructureTags() }
  2.  
  3.  
  4. {$I "Include:Utility/TagItem.i"}
  5.  
  6. { PackTable definition:
  7.  *
  8.  * The PackTable is a simple array of LONGWORDS that are evaluated by
  9.  * PackStructureTags() and UnpackStructureTags().
  10.  *
  11.  * The table contains compressed information such as the tag offset from
  12.  * the base tag. The tag offset has a limited range so the base tag is
  13.  * defined in the first longword.
  14.  *
  15.  * After the first longword, the fields look as follows:
  16.  *
  17.  *      +--------- 1 = signed, 0 = unsigned (for bits, 1=inverted boolean)
  18.  *      |
  19.  *      |  +------ 00 = Pack/Unpack, 10 = Pack, 01 = Unpack, 11 = special
  20.  *      | / \
  21.  *      | | |  +-- 00 = Byte, 01 = Word, 10 = Long, 11 = Bit
  22.  *      | | | / \
  23.  *      | | | | | /----- For bit operations: 1 = TAG_EXISTS is TRUE
  24.  *      | | | | | |
  25.  *      | | | | | | /-------------------- Tag offset from base tag value
  26.  *      | | | | | | |                 \
  27.  *      m n n o o p q q q q q q q q q q r r r s s s s s s s s s s s s s
  28.  *                                      \   | |               |
  29.  *      Bit offset (for bit operations) ----/ |               |
  30.  *                                            \                       |
  31.  *      Offset into data structure -----------------------------------/
  32.  *
  33.  * A -1 longword signifies that the next longword will be a new base tag
  34.  *
  35.  * A 0 longword signifies that it is the end of the pack table.
  36.  *
  37.  * What this implies is that there are only 13-bits of address offset
  38.  * and 10 bits for tag offsets from the base tag.  For most uses this
  39.  * should be enough, but when this is not, either multiple pack tables
  40.  * or a pack table with extra base tags would be able to do the trick.
  41.  * The goal here was to make the tables small and yet flexible enough to
  42.  * handle most cases.
  43.  }
  44.  
  45. const
  46.  PSTB_SIGNED =31;
  47.  PSTB_UNPACK =30;    { Note that these are active low... }
  48.  PSTB_PACK   =29;    { Note that these are active low... }
  49.  PSTB_EXISTS =26;    { Tag exists bit true flag hack...  }
  50.  
  51.  PSTF_SIGNED = 2147483648;
  52.  PSTF_UNPACK = 1073741824;
  53.  PSTF_PACK   = 536870912;
  54.  
  55.  PSTF_EXISTS = 67108864;
  56.  
  57.  
  58. {***************************************************************************}
  59.  
  60.  
  61.  PKCTRL_PACKUNPACK = $00000000;
  62.  PKCTRL_PACKONLY   = $40000000;
  63.  PKCTRL_UNPACKONLY = $20000000;
  64.  
  65.  PKCTRL_BYTE       = $80000000;
  66.  PKCTRL_WORD       = $88000000;
  67.  PKCTRL_LONG       = $90000000;
  68.  
  69.  PKCTRL_UBYTE      = $00000000;
  70.  PKCTRL_UWORD      = $08000000;
  71.  PKCTRL_ULONG      = $10000000;
  72.  
  73.  PKCTRL_BIT        = $18000000;
  74.  PKCTRL_FLIPBIT    = $98000000;
  75.  
  76.  
  77. {***************************************************************************}
  78.  
  79.  
  80. { Macros used by the next batch of macros below. Normally, you don't use
  81.  * this batch directly. Then again, some folks are wierd
  82.  }
  83.  
  84.  
  85.  
  86. {***************************************************************************}
  87.  
  88.  
  89. { Some handy dandy macros to easily create pack tables
  90.  *
  91.  * Use PACK_STARTTABLE() at the start of a pack table. You pass it the
  92.  * base tag value that will be handled in the following chunk of the pack
  93.  * table.
  94.  *
  95.  * PACK_ENDTABLE() is used to mark the end of a pack table.
  96.  *
  97.  * PACK_NEWOFFSET() lets you change the base tag value used for subsequent
  98.  * entries in the table
  99.  *
  100.  * PACK_ENTRY() lets you define an entry in the pack table. You pass it the
  101.  * base tag value, the tag of interest, the type of the structure to use,
  102.  * the field name in the structure to affect and control bits (combinations of
  103.  * the various PKCTRL_XXX bits)
  104.  *
  105.  * PACK_BYTEBIT() lets you define a bit-control entry in the pack table. You
  106.  * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
  107.  * affects. This macro should be used when the field being affected is byte
  108.  * sized.
  109.  *
  110.  * PACK_WORDBIT() lets you define a bit-control entry in the pack table. You
  111.  * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
  112.  * affects. This macro should be used when the field being affected is word
  113.  * sized.
  114.  *
  115.  * PACK_LONGBIT() lets you define a bit-control entry in the pack table. You
  116.  * pass it the same data as PACK_ENTRY, plus the flag bit pattern this tag
  117.  * affects. This macro should be used when the field being affected is longword
  118.  * sized.
  119.  *
  120.  * EXAMPLE:
  121.  *
  122.  *    ULONG packTable[] =
  123.  *    (
  124.  *         PACK_STARTTABLE(GA_Dummy),
  125.  *         PACK_ENTRY(GA_Dummy,GA_Left,Gadget,LeftEdge,PKCTRL_WORD|PKCTRL_PACKUNPACK),
  126.  *         PACK_ENTRY(GA_Dummy,GA_Top,Gadget,TopEdge,PKCTRL_WORD|PKCTRL_PACKUNPACK),
  127.  *         PACK_ENTRY(GA_Dummy,GA_Width,Gadget,Width,PKCTRL_UWORD|PKCTRL_PACKUNPACK),
  128.  *         PACK_ENTRY(GA_Dummy,GA_Height,Gadget,Height,PKCTRL_UWORD|PKCTRL_PACKUNPACK),
  129.  *         PACK_WORDBIT(GA_Dummy,GA_RelVerify,Gadget,Activation,PKCTRL_BIT|PKCTRL_PACKUNPACK,GACT_RELVERIFY)
  130.  *         PACK_ENDTABLE
  131.  *    );
  132.  }
  133.  
  134.